﻿using CuaHangLego.Bussiness;
using CuaHangLego.DataAccess;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CuaHangLego.UI
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }
        private void LoadUI(object sender, EventArgs e)
        {
            DisableAll();
            while (this.panelMain.Controls.Count > 0)
                this.panelMain.Controls.RemoveAt(0);
            this.panelMain.Controls.Add(new Login(this));

        }

        public void LoadSanPhamUI()
        {
            while (this.panelMain.Controls.Count > 0)
                this.panelMain.Controls.RemoveAt(0);
            this.panelMain.Controls.Add(new QLSanPhamUI());
        }

        public void LoadKhoUI()
        {
            while (this.panelMain.Controls.Count > 0)
                this.panelMain.Controls.RemoveAt(0);
            this.panelMain.Controls.Add(new QLKhoUI());
        }

        public void LoadHoaDonUI()
        {
            while (this.panelMain.Controls.Count > 0)
                this.panelMain.Controls.RemoveAt(0);
            this.panelMain.Controls.Add(new QLHoaDonUI());
        }

        public void LoadDoanhSoUI()
        {
            while (this.panelMain.Controls.Count > 0)
                this.panelMain.Controls.RemoveAt(0);
            this.panelMain.Controls.Add(new QLDoanhThuUI());
        }

        public void LoadKhachHangUI()
        {
            while (this.panelMain.Controls.Count > 0)
                this.panelMain.Controls.RemoveAt(0);
            this.panelMain.Controls.Add(new QLKhachHangUI());
        }

        public void LoadNCCUI()
        {
            while (this.panelMain.Controls.Count > 0)
                this.panelMain.Controls.RemoveAt(0);
            this.panelMain.Controls.Add(new QLNhaCungCapUI());
        }

        public void LoadLoginUI()
        {
            DisableAll();
            while (this.panelMain.Controls.Count > 0)
                this.panelMain.Controls.RemoveAt(0);
            this.panelMain.Controls.Add(new Login(this));
        }

        public void LoadHomeUI()
        {
            while (this.panelMain.Controls.Count > 0)
                this.panelMain.Controls.RemoveAt(0);
            this.panelMain.Controls.Add(new Home(this));
        }

        public void EnableAll()
        {
            this.ControlPanel.Enabled = true;
            this.menuBar.Enabled = true;
            while (this.panelMain.Controls.Count > 0)
                this.panelMain.Controls.RemoveAt(0);
            this.panelMain.Controls.Add(new Home(this));
        }

        public void DisableAll()
        {
            this.ControlPanel.Enabled = false;
            this.menuBar.Enabled = false;
        }

        private void tsmHome_Click(object sender, EventArgs e)
        {
            LoadHomeUI();
        }

        private void tsmDangXuat_Click(object sender, EventArgs e)
        {
            LoadLoginUI();
        }

        private void tsmTrangChu_Click(object sender, EventArgs e)
        {
            LoadHomeUI();
        }

        private void tsmThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void tsmSP_Click(object sender, EventArgs e)
        {
            LoadSanPhamUI();
        }

        private void tsmHD_Click(object sender, EventArgs e)
        {
            LoadHoaDonUI();
        }

        private void tsmKho_Click(object sender, EventArgs e)
        {
            LoadKhoUI();
        }

        private void tsmDoanhSo_Click(object sender, EventArgs e)
        {
            LoadDoanhSoUI();
        }
        private void tsmQLSP_Click(object sender, EventArgs e)
        {
            LoadSanPhamUI();
        }

        private void tsmQLKho_Click(object sender, EventArgs e)
        {
            LoadKhoUI();
        }

        private void tsmQLHoaDon_Click(object sender, EventArgs e)
        {
            LoadHoaDonUI();
        }

        private void tsmAbout_Click(object sender, EventArgs e)
        {
            new AboutBox().ShowDialog();
        }

        private void tsmQLKH_Click(object sender, EventArgs e)
        {
            LoadKhachHangUI();
        }

        private void tsmQLNCC_Click(object sender, EventArgs e)
        {
            LoadNCCUI();
        }

        private void NCCToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LoadNCCUI();
        }

        private void KHToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LoadKhoUI();
        }
    }
}
